/*2
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
package terrain;
import com.jme3.terrain.geomipmap.TerrainQuad;
/**
 * <code>TerrainSurfaceInfo</code> defines information about a TerrainSurface
 * shared by TerrainSurface and TerrainSurfaceFactory.
 * @author Vemund Kvam (@makeshift)
 */
  public class TerrainSurfaceInfo{
    protected TerrainQuad terrain;
    protected int terrainSize;
    protected int terrainSquaredSize;
    protected int terrainHalfSize;
    
    protected boolean createShape;
    protected boolean findVolume;
    
    protected int lod;
    protected int lodSquared;

    /**
     * Creates an empty TerrainSurfaceInfo object. Data needs to be added before it can be used.
     */
    public TerrainSurfaceInfo(){
    }    
    /**
     * Create a TerrainSurfaceInfo object with all needed variables.
     */    
    public TerrainSurfaceInfo(boolean createShape,boolean findVolume, int lod,TerrainQuad terrain){
    setTerrain(terrain);
    setLod(lod);
    this.createShape = createShape;
    this.findVolume = findVolume;
    }
    public final void setTerrain(TerrainQuad terrain){
        if (terrain == null) {
        throw new NullPointerException();
        }
    this.terrain = terrain;
    this.terrainSize  = terrain.getTerrainSize();
    this.terrainSquaredSize = terrainSize*terrainSize;
    this.terrainHalfSize = terrainSize/2;    
    }
    
    /**
     * Returns the TerrainQuad.
     * 
     * @return the TerrainQuad that is used by this TerrainSurfaceInfo.
     */    
    public TerrainQuad getTerrain(){
    return terrain;
    }
    /**
     * Sets the lod value used by TerrainSurfaceFactory under TerrainSurface
     * construction and by TerrainSurface under Mesh/Geometry construction.
     * 
     * @return the TerrainQuad that is used by this TerrainSurfaceInfo.
     */  
    public final void setLod(int lod){
        if (lod < 1) {
        throw new IllegalArgumentException("LOD level is out of range: " + lod);
        }
    this.lod = lod;
    this.lodSquared = lod*lod;
    }
    public int getLod(){
    return lod;
    }    
    public void setFindVolume(boolean findVolume){
    this.findVolume = findVolume;
    }
    public boolean getFindVolume(){
    return findVolume;
    }
    public void setCreateShape(boolean createShape){
    this.createShape = createShape;
    }
    public boolean getCreateShape(){
    return createShape;
    }
  }